{extend name="admin/public/base" /}

{block name="content"}
<!-- Content Header (Page header) -->
<section class="content-header">
  <h1>
    主题设置
    <small></small>
  </h1>
  <ol class="breadcrumb">
    <li><a href="#"><i class="fa fa-dashboard"></i> 首页</a></li>
    <li><a href="#">系统</a></li>
    <li class="active">主题设置</li>
  </ol>
</section>

<!-- Main content -->
<section class="content">

    <div class="row text-center">
        {volist name="list" id="vo"}
            <div class="col-sm-3">
                <div class="box box-solid">
                    <div class="box-body">
                        <div class="thumbnail">
                            <img class="img-responsive" src="{$vo.logo}" alt="Photo">
                        </div>
                        <div class="caption">
                            {eq name="theme" value="$vo.name"}
                            <button type="button" class="btn btn-primary btn-flat" role="button">已启用</button>
                            {else/}
                            <button type="button" class="btn btn-default btn-flat" onclick="change('{$vo.name}')" role="button">启用</button>
                            {/eq}
                        </div>
                    </div>
                </div>
            </div>
            <!-- /.col -->
        {/volist}
    </div>

</section>
<!-- /.content -->
{/block}

{block name="js"}
<script>
    function change(name){
            swal({
                title: "确定使用这个主题吗?",
                text: "",
                type: "warning",
                showCancelButton: true,
                confirmButtonColor: "#DD6B55",
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                closeOnConfirm: false,
                closeOnCancel: false },
            function (isConfirm) {
                if (isConfirm) {
                    $.ajax({
                        url:"{:url('admin/theme/change')}",
                        data:{'name':name},
                        type:'post',
                        dataType:'json',
                        success: function(xhr){
                            if(xhr.code == 200){
                                swal(xhr.msg, "", "success");
                                window.location.reload();
                            }else{
                                swal(xhr.msg, "", "error");
                            }
                        }
                    })
                } else {
                    swal("取消操作", "", "error");
                }
            });
    }
</script>
{/block}
